﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CNFM_CROCODILE_LOGO.Core.Domain.ViewModels;
using CNFM_CROCODILE_LOGO.Services.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace CNFM_CROCODILE_LOGO_Web.Controllers
{
    /// <summary>
    /// 菜单管理
    /// </summary>
    public class MenuController : Controller
    {
        private IBasicServices _pro;

        public MenuController(IBasicServices pro)
        {
            this._pro = pro;
        }

        /// <summary>
        /// 菜单列表
        /// </summary>
        /// <returns></returns>
        public IActionResult List()
        {
            return View();
        }

        /// <summary>
        /// 菜单新增
        /// </summary>
        /// <returns></returns>
        public IActionResult Add()
        {
            return View();
        }

        /// <summary>
        /// 菜单列表
        /// </summary>
        /// <param name="index"></param>
        /// <param name="size"></param>
        /// <param name="sasearch"></param>
        /// <returns></returns>
        public JsonResult GetMenuAll(int index, int size, string sasearch)
        {
            var ret = _pro.GetMenuAll(index, size, sasearch);
            return Json(ret);
        }

        /// <summary>
        /// 菜单新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [Authorize("Permission")]

        public JsonResult AddUpdateMenuAll([FromBody]MenuModels model)
        {
            var ret = _pro.AddUpdateMenuAll(model);
            return Json(ret);
        }

        /// <summary>
        /// 菜单删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult DeleteMenu(string id)
        {
            var ret = _pro.DeleteMenu(id);
            return Json(id);
        }

        /// <summary>
        /// 菜单树
        /// </summary>
        /// <returns></returns>
        public JsonResult MenuTree()
        {
            var ret = _pro.MenuTree();
            return Json(ret);
        }

        /// <summary>
        /// 菜单下拉
        /// </summary>
        /// <returns></returns>
        public JsonResult MenuSelect()
        {
            var ret = _pro.MenuSelect();
            return Json(ret);
        }
    }
}